﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.Configuration;
using PSE.ProcessManager.Common.Configuration;
using System.ServiceModel;

namespace PSE.ProcessManager.Common.Gateway
{
    public class ServiceManagerSenderGateway : SenderGateway
    {
        private string _productName;
        private string _instanceName;

        public ServiceManagerSenderGateway(string productName, string instanceName)
            : base()
        {
            _productName = productName;
            _instanceName = instanceName;

            this.IsConnected = true;

            this.Address = string.Format("net.pipe://localhost/Listener/InteligenceManager/{0}/{1}", productName, instanceName);
        }

        protected override IListenerService CreateProxy(EndpointAddress endpoint)
        {
            NetNamedPipeBinding namedPipeBinding = new NetNamedPipeBinding();
            IListenerService proxy = DuplexChannelFactory<IListenerService>.CreateChannel(_instanceCallback, namedPipeBinding, endpoint);
            return proxy;
        }
    }
}
